﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Antu.WebControls;
using Antu.Core.Components;
using Antu.Core.Services;
using System.Web.UI.WebControls;
using EluZSProvider;
using System.Web;
using System.Data;
using Antu.Core.DataAccess;

namespace WebSys.UI.Control.ZhengShou
{
    public class profujianControl : MPBasicTemplate
    {
        EluZSDataProvider _EluZSDataProvider = (EluZSDataProvider)ProviderService.ProviderServiceMange.GetProvider("EluZSProvider");
        public string userid = string.Empty;
        string iid;
        Repeater fujianlist;
        protected override void CreateChildControls()
        {

            base.CreateChildControls();
        }
        protected override void OnLoad(EventArgs e)
        {
            if (HttpContext.Current.Session["UserID"] == null)
            {
                Antu.Utilities.UtilitiesPage.AlertDialogClear("登录超时，请重新登录！", "window.parent.location.href('../login.aspx');");
            }
            else
            {
                userid = HttpContext.Current.Session["UserID"].ToString();
            }
            fujianlist = (Repeater)FindControl("fujianlist");
            iid = base.Page.Request["iid"];
            base.OnLoad(e);
            if (!base.Page.IsPostBack)
            {
                Bind();
            }
        }
        private void Bind()
        {
            DataSet ds = new DataSet();
            string sql = string.Format(@"select t.*,( case when t.keyname='建设用地批准书' then 
        (select count(*) from zs_file tt where tt.itemname ='土地权属证明文件' and 
        tt.itemid in (select pid from zs_zzbcjfenhu where id in (   
select 关联ID from xt_instance_ext where IID='{0}'))) 
when t.keyname='建设项目可行性研究报告的批复' then 
        (select count(*) from zs_file tt where tt.itemname ='项目批准文件' and 
        tt.itemid in (select pid from zs_zzbcjfenhu where id in (   
select 关联ID from xt_instance_ext where IID='{0}'))) 
when t.keyname='建设用地规划许可证' then 
        (select count(*) from zs_file tt where tt.itemname ='规划许可文件' and 
        tt.itemid in (select pid from zs_zzbcjfenhu where id in (   
select 关联ID from xt_instance_ext where IID='{0}'))) 
else (Select Count(*)
          From zs_file tt
         where tt.type = t.keyname  And tt.itemid='{0}') end    ) filecount from zs_params t 
where name='决定附件类型' ", iid);
            ds = _EluZSDataProvider.GetOneDs("(" + sql + ")", "*", "");
            fujianlist.DataSource = ds;
            fujianlist.DataBind();
        }
    }
}


